Make transition() tolerances dynamic and fix its argument list (VAMS-2023, Mantis 7810) - #30
Merged
Merged
Conversation
…2023)
VAMS-2023 Table 4-20 (Mantis 7810) moves the tolerance arguments of the
event functions and of transition() from the "constant expression
arguments" column to the "dynamic expression arguments" column. For
transition() the LRM form is
transition ( expr [ , td [ , rise_time [ , fall_time [ , time_tol ] ] ] ] )
OpenVAF got two things wrong here:
- the signature list stopped at four arguments, and the arities were off
by one from the third signature onwards
(`TRANSITION_DELAY_RISET` took two arguments, not three). The full
five-argument LRM form was rejected outright with "invalid argument
count", and - worse - the four-argument form `transition(x, td, tr,
tf)` matched the signature named `..._TOL`, so `fall_time` was
const-checked and a run-time fall time was rejected with "constant
expressions must not contain variable references".
- with the arities corrected, `time_tol` would still have been
const-checked. Per Table 4-20 it is now a dynamic expression, so
transition() is removed from the const-expression list in body
validation. The tolerances that Table 4-20 *keeps* constant -
absdelay's `maxdelay`, ddt's and idt/idtmod's `abstol` - are
deliberately left alone.
Lowering already read `args[2]`/`args[3]` as the rise and fall time, so
it needed no change; `td` and `time_tol` do not affect the continuous
(first-order lag) realization and are documented as ignored.
Also fixes the "too many arguments" diagnostic, which reported
`min_args` instead of `max_args` and so said "expected at most 1
arguments" for every over-long call to an operator with optional
arguments.
Not touched: `cross`, `above`, `timer` and `absdelta`. Their tolerances
are already unrestricted because OpenVAF does not resolve the event
expression of `@(...)` at all yet, so there is nothing to relax; giving
them real signatures is a separate change.
Tests:
- ui/transition_tolerance.va: all five argument counts accepted, and a
run-time rise time, fall time and time tolerance accepted, with no
diagnostics. The four- and five-argument cases both failed before.
- ui/transition_tolerance_err.log: six arguments still rejected (now
with the correct maximum in the message) and ddt/absdelay tolerances
still required to be constant.
- integration_tests/VAMS2023_TRANSITION_TOL + the OSDI snapshot:
end-to-end compile/link/load of a model whose transition rise time,
fall time and tolerance are all computed at run time.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the VAMS-2023 alignment effort tracked in #19.
Summary
VAMS-2023 Table 4-20 (Mantis 7810) moves the tolerance arguments of the analog event functions and of
transition()out of the constant expression arguments column and into the dynamic expression arguments column. In VAMS 2.4 the same table liststransition'stime_tolas a constant argument; in VAMS-2023 all five of its arguments are dynamic:OpenVAF got two separate things wrong here.
1. The signature list was truncated and mis-numbered. It stopped at four arguments and the arities were off by one from the third signature onwards (
TRANSITION_DELAY_RISETtook two arguments, not three). Two consequences onmobtoday:2.
time_tolwas const-checked. With the arities corrected it still would have been, sotransitionis removed from the const-expression list in body validation. The tolerances Table 4-20 keeps constant —absdelay'smaxdelay,ddt's andidt/idtmod'sabstol— are deliberately left alone.Lowering already read
args[2]/args[3]as the rise and fall time, so it needed no change.tdandtime_toldo not affect the continuous (first-order lag) realization and are now documented as ignored rather than silently dropped.Drive-by fix
The "too many arguments" diagnostic reported
min_argsinstead ofmax_args, so every over-long call to an operator with optional arguments said "expected at most 1 arguments". It now reports the real maximum.Deliberately not in scope
cross,above,timerandabsdelta. Their tolerance arguments are already unrestricted, because OpenVAF does not resolve the event expression of@(...)at all yet — there is nothing to relax. Giving those four real signatures is a separate change with its own regression surface.Test plan
openvaf/test_data/ui/transition_tolerance.va— all five argument counts, plus a run-time rise time, fall time and time tolerance; compiles with an empty diagnostics log. The four- and five-argument cases both failed before this change.openvaf/test_data/ui/transition_tolerance_err.{va,log}— six arguments still rejected (now with the correct maximum in the message), andddt/absdelaytolerances still required to be constant expressions.integration_tests/VAMS2023_TRANSITION_TOL/+openvaf/test_data/osdi/vams2023_transition_tol.snap— end-to-end compile / link / load of a model whose transition rise time, fall time and tolerance are all computed at run time.--dump-unopt-mirshows the lag's time constant selected from the dynamic rise/fall values (phi [speed], [2*speed]) rather than from constants.Verified locally with LLVM 18:
🤖 Generated with Claude Code